/**
 * @description **存储本地数据；（可存储多个数据，支持对象存储；）**
 * @param {json} obj - 接收json对象格式的数据
 * @example
 *
 * ```js
 * let opt={
 *    uid:'01',
 *    userInfo:{ //以对象方式存储
 *       name:'Tom',
 *       age:18
 *    }
 * }
 * localStorageAdd(opt)
 * ```
 */
const localStorageAdd=(obj)=>{
   for(let name in obj){
       if(typeof obj[name]=='object'){
           //是对象则需先转换为字符串    
           localStorage.setItem(name,JSON.stringify(obj[name]))
       }else{
           //非对象逐个存储    
           localStorage.setItem(name,obj[name])
       }
   }
}

export default localStorageAdd;